\ProvidesPackage{styles/environments}

%----------------------------------------------------------------------------------------
%	ITEMS
%----------------------------------------------------------------------------------------

\usepackage{amssymb}
\renewcommand{\labelitemi}{\small$\blacktriangleright$}
\renewcommand{\labelitemii}{\textbullet}
\usepackage{enumitem}
\setlist[itemize]{noitemsep}
\setlist[enumerate]{noitemsep}
\setlist[description]{noitemsep}

%----------------------------------------------------------------------------------------
%	SIMPLE BOXED ENVIRONMENT
%----------------------------------------------------------------------------------------

% kaobox (while tcolorbox may be more rich, I find it too complicated so I prefer mdframed)
\usepackage{tikz}
\usepackage[framemethod=TikZ]{mdframed}

%\mdfsetup{skipabove=\topskip,skipbelow=0pt}
\mdfdefinestyle{kaoboxstyle}{
	skipabove=1.5\topskip,
	skipbelow=.5\topskip,
	rightmargin=0pt,
	leftmargin=0pt,
	%innertopmargin=3pt,
	%innerbottommargin=3pt,
	innerrightmargin=7pt,
	innerleftmargin=7pt,
	topline=false,
	bottomline=false,
	rightline=false,
	leftline=false,
	%linewidth=1pt,
	%roundcorner=0pt,
	%font={},
	%frametitlefont={},
	frametitlealignment=\raggedright\noindent,
	frametitlerule=true,
	linecolor=black,
	%backgroundcolor=LightBlue,
	fontcolor=black,
	%frametitlebackgroundcolor=LightBlue,
}

\newmdenv[
	style=kaoboxstyle,
	backgroundcolor=RoyalBlue!25!White,
	frametitlebackgroundcolor=RoyalBlue!25!White,
]{kaobox}

%----------------------------------------------------------------------------------------
%	ENVIRONMENT WITH A COUNTER
%----------------------------------------------------------------------------------------

\newenvironment{kaocounter}{
	\refstepcounter{kaocounter}
	\begin{kaobox}[frametitle=注释~\thekaocounter\autodot]
}{
	\end{kaobox}
}

\newcounter{kaocounter}
\numberwithin{kaocounter}{section}
\newcommand*{\kaocounterformat}{% Format for the caption
	Comment~\thekaocounter\csname autodot\endcsname}
\newcommand*{\fnum@kaocounter}{\kaocounterformat}


%----------------------------------------------------------------------------------------
%	FLOATING ENVIRONMENT WITH TOC ENTRIES
%----------------------------------------------------------------------------------------

\newenvironment{kaofloating}{%
	\@float{kaofloating}%
}{%
	\end@float
}

\newcommand*{\fps@floatingbox}{tbph}
\newcommand*{\ftype@floatingbox}{5}
\newcommand*{\floatingboxformat}{%
	Insight~\thefloatingbox\csname autodot\endcsname}
\newcommand*{\fnum@floatingbox}{\floatingboxformat}
\newcommand*{\ext@floatingbox}{loi}

\addtotoclist[float]{loi}
\newcommand*{\listofloiname}{List of Insights}
\newcommand*{\l@floatingbox}{\l@figure}
\newcommand*{\listofinsights}{\listoftoc{loi}}

%----------------------------------------------------------------------------------------
%	CITATION ENVIRONMENT
%----------------------------------------------------------------------------------------

% TODO: create a fancy environment for this. Perhaps printing also the 
% abstract.

% Cite commands (assuming biblatex is loaded)
\DeclareCiteCommand{\fullcite}{%
	\defcounter{maxnames}{99}%
	\usebibmacro{prenote}}
	{\clearfield{url}%
	\clearfield{pages}%
	\clearfield{pagetotal}%
	\clearfield{edition}%
	\clearfield{issn}%
	\clearfield{doi}%
	\usedriver
	{\DeclareNameAlias{sortname}{default}}
	{\thefield{entrytype}}
}
{\multicitedelim}
{\usebibmacro{postnote}}
